<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="__CSS__/main.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/common.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/bootstrap.min.css" />
    <script type="text/javascript" src="__EXTEND__/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="__EXTEND__/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__EXTEND__/lib/layer/2.4/layer.js"></script>
    <![endif]-->
    <title></title>
</head>
<body>
<div class="contant">
<div class="row">
    <div class="top">资产部>GPS设备待审列表</div>
    <div class="content applylist">
        <div class="box">
            <h1>GPS设备待审列表</h1>
            <div class="list-block">
                <div class="row">
                    <table class="list">
                        <tr>
                            <th>申请人</th> <th>数量</th><th>状态</th> <th>供应商</th> <th>备注</th><th>操作</th>
                        </tr>
                            <foreach name="list" item="_gps" >
                        <tr>
                                <td>{$_gps.name}</td>
                                <td>{$_gps.total_stock}</td>
                                <td>
                                    <switch name="_gps.status">
                                        <case value="0">通过</case>
                                        <case value="1">草稿</case>
                                        <case value="2">待审</case>
                                        <case value="3">删除</case>
                                        <case value="4">申请设备待审</case>
                                        <case value="5">申请设备通过</case>
                                        <default />default
                                    </switch>
                                </td>
                                <td>{$_gps.suppliers}</td>
                                <td>{$_gps.note}</td>
                            <td><a class="check-through" data-id={$_gps.id} href="javascript:void(0);">同意</a></td>
                        </tr>
                            </foreach>
                        <tr><td colspan="6">待审数：{$sumStock}</td></tr>
                    </table>
                </div>
                {$page}
            </div>
        </div>
    </div>
</div>
</div>

<!-- Modal -->
<div class="modal fade" id="importGPS" tabindex="-1" role="dialog" aria-labelledby="importGPSLabel">
<form name="gpsForm" id="gpsForm">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span class="close-div" aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="importGPSLabel">上传出库表</h4>
      </div>
      <div class="modal-body">
        <div id="">
            <label>选择供应商:</label>
            <select id="point-obj" name="_suppliers" class="form-control">
                <option value=赛格>赛格</option>
                <option value=杨利伟>杨利伟</option>
                <option value=倪根鸣>倪根鸣</option>
            </select>
            <input type="hidden" name="gps_id" id="gps-id">
        </div>
        <div id="">
            <label>上传出库表:</label>
            <input type="file" name="gps_excel">
        </div>
      </div>

      <div class="modal-footer">
        <button type="button" class="btn btn-default close-div" data-dismiss="modal">取消</button>
        <button id="query" type="button" class="btn btn-primary">确认</button>
      </div>
    </div>
  </div>
</form>
</div>

<script type="text/javascript">

    $('.close-div').click(function(){
        $('#importGPS').removeClass('in').css('display','none');
    });

    $('#query').click(function(){
        var data = new FormData($('#gpsForm')[0]);
            $.ajax({
                url: '__URL__/importGps',
                type: 'POST',
                data: data,
                dataType: 'JSON',
                cache: false,
                processData: false,
                contentType: false
            }).done(function(ret){
                console.log(ret);
                if(ret['status']){
                    $('#importGPS').removeClass('in').css('display','none');
                    window.location.reload();
                }else{
                    alert(ret['errorMsg']);
                }
            });
            return false;
    });


    $('.check-through').click(function(elm){
        if (confirm('确定审核通过吗？') == true){
            var gpsId = $(this).attr('data-id');
            $('#gps-id').val(gpsId);

            $.ajax({
                type: "POST",
                url: "__URL__/checkEquipYes",
                data: {
                    gpsId:gpsId
                },
                success: function(msg){
                    console.log(msg);
                    if (msg) {
                        alert('已经审核通过，请导入出库记录');
                    }
                    // window.location.href = "http://www.jb51.net";
                    $('#importGPS').addClass('in').css('display','block');
               }
            });

        }
    });

    // $('#query').click(function(){
    //       $.ajax({
    //             type: "POST",
    //             url: "__URL__/importGPS",
    //             data: {
    //                 gpsId:gpsId
    //             },
    //             success: function(msg){
    //                 console.log(msg);
    //                 if (msg) {
    //                     alert('已经审核通过，请导入出库记录');
    //                 }
    //                 // window.location.href = "http://www.jb51.net";
    //                 $('#importGPS').addClass('in').css('display','block');
    //                 // window.location.reload();
    //            }
    //         });
    //
    // });
</script>
</body>
</html>